<template>
	<view>
		<u-tabbar
			:value="this.$store.state.tabberName"
			@change="fixedClick"
		>
			<block v-for="item in list">
				<u-tabbar-item :text="item.text" :icon="item.icon" :name="item.name"  @click="onClick"></u-tabbar-item>
			</block>
		</u-tabbar>
	</view>
</template>

<script>
	export default {
		name:"u-tabber",
		data() {
			return {
				list: [{
					icon: "home",
					text: "首页",
					name: "home",
					pagePath: "../../pages/home/index"
					},
					{
					icon: "search",
					text: "发现",
					name: "find",
					pagePath: "../../pages/find/index"
					},
					{
					icon: "chat",
					text: "消息",
					name: "news",
					pagePath: "../../pages/news/index"
					},
					{
					icon: "account",
					text: "账户",
					name: "user",
					pagePath: "../../pages/user/index"
					}],
				current: 0,
				disabled: true,
			};
		},
		onLoad() {
			// 隐藏底部tabber
			uni.hideTabBar({})
		},
		methods:{
			fixedClick(e) {
				console.log('fixedClick', e);
				
				// if (e === 1) return uni.$u.toast('请您先登录')
				// 	else this.tabberValue = e
				// console.log("this.$store.state.tabberName => ", this.$store.state.tabberName);
			},
			onClick(e) {
				this.$store.commit('setTabbarName', e)
				this.list.forEach(item => {
					if (item.name == e) {
						uni.switchTab({url: item.pagePath})
					}
				})
			}
		}
	}
</script>

<style>

</style>
